package generator;

import generator.bean.Plugin;
import generator.service.PropertiesService;
import generator.service.TemplateService;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.log4j.Logger;


public class BeanGeneratorTool
{
    private static final Logger logger = Logger.getLogger( BeanGeneratorTool.class );

    public static void run( )
    {
        PropertiesService.init( );
        TemplateService _templateService = new TemplateService( );

        String pathProjet = PropertiesService.PATH_PROJECT;
        String separator = GeneratorConstants.PATH_SEPARATOR;
        String folderSource = PropertiesService.getProperty( GeneratorConstants.KEY_FOLDER_SOURCE );

        String pathSources = pathProjet + separator + folderSource;
        _templateService.setPathFolderWithTemplate( pathSources );

        Plugin plugin = null;
        try
        {
            plugin = PropertiesService.getPlugin( );
        }
        catch ( IllegalAccessException e )
        {
            logger.error( e );
        }
        catch ( IllegalArgumentException e )
        {
            logger.error( e );
        }
        catch ( InvocationTargetException e )
        {
            logger.error( e );
        }

        List<String> templates = _templateService.getTemplatesFiles( pathSources );
        List<String> files = _templateService.applyRulesForTemplates( plugin, templates );
        logger.debug( files );

    }

}
